package com.ysd.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.impl.NewsDaolmpl;
import com.ysd.impl.Produc2tDaoImpl;
import com.ysd.impl.ProductcategoryDaolmpl;
import com.ysd.entity.News;
import com.ysd.entity.Product;
import com.ysd.entity.Productcategory;
public class ProductDetailServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		ProductcategoryDaolmpl pro = new ProductcategoryDaolmpl();
		List<Productcategory> produ = pro.getProductcategory();
		request.setAttribute("produ", produ);
		
		int pId=Integer.parseInt(request.getParameter("productId"));
		Produc2tDaoImpl rDao=new Produc2tDaoImpl();
		List<Product> pd=rDao.getProductList(pId);
		request.setAttribute("pd", pd);
		System.out.println(pd);
		
		Produc2tDaoImpl pDao = new Produc2tDaoImpl();
		List<Product> pr = pDao.getProductList();
		request.setAttribute("pr", pr);
		
		

		request.getRequestDispatcher("productdetails.jsp").forward(request, response);
	}
	
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
